Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-color

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-color

Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is d3-color?

The d3-color npm package provides a robust framework for color manipulation and conversion. It allows users to parse color strings, manipulate colors in different color spaces, and format colors for display. It is part of the larger D3 (Data-Driven Documents) suite of tools, which are used for manipulating documents based on data.

What are d3-color's main functionalities?

Parsing and Formatting Colors

This feature allows users to parse CSS color strings and then format them back into a string. The example shows how to parse 'steelblue' into a color object and then output it as an RGB string.

"var color = d3.color('steelblue');\nconsole.log(color.toString()); // 'rgb(70, 130, 180)'"

Manipulating Color Channels

Users can directly manipulate the channels of a color, including its opacity. In the example, an RGB color is created and its opacity is set before converting it back to a string.

"var color = d3.rgb(70, 130, 180);\ncolor.opacity = 0.5;\nconsole.log(color.toString()); // 'rgba(70, 130, 180, 0.5)'"

Working with Different Color Spaces

d3-color supports various color spaces such as RGB, HSL, and LAB. This example demonstrates converting an HSL color to its equivalent RGB string.

"var color = d3.hsl(210, 0.44, 0.49);\nconsole.log(color.toString()); // 'rgb(70, 130, 180)'"

Other packages similar to d3-color

Keywords

FAQs

Package last updated on 28 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc